"""91美剧网，爬取m3u8视频"""
import requests

# # 美国恐怖故事,获取m3u8文件
# url ="https://new.qqaku.com/20221020/IECNh93K/1100kb/hls/index.m3u8"
# res = requests.get(url)
# # print(res.text)
# with open("../数据暂存/美国恐怖故事.m3u8", "wb") as f:
#     f.write(res.content)
n = 1
with open("../数据暂存/美国恐怖故事.m3u8", "r", encoding='utf-8') as f:
    for line in f:
        line = line.strip()
        if line.startswith("#"):
            continue
        res1 = requests.get(line)
        f = open(f"../数据暂存/test.ts", "ab")
        f.write(res1.content)
        f.close()
        print(n, "已下载完成")
        n += 1
        if n == 11:
            break
        # f.close()
        # 仅仅是添加一个无用的备注
